package com.study.bigevent.mapper;

import com.study.bigevent.pojo.Article;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ArticleMapper {
    @Insert("insert into article(title,content,cover_img,state,category_id,create_user,create_time,update_time)" +
            "values (#{title},#{content},#{coverImg},#{state},#{categoryId},#{createUser},#{createTime},#{updateTime})")
    void add(Article article);

    /**
     * 根据用户ID、分类ID和状态获取文章列表
     * @param userId 用户ID
     * @param categoryId 分类ID
     * @param state 文章状态
     * @return 文章列表
     */
    List<Article> list(Integer userId, Integer categoryId, String state);
    @Select("select * from article where id = #{id}")
    Article findById(Integer id);
}
